import { sequelize } from './sequelize.js';
import User from './model/User.js'



// 同步模型到数据库
export const sync = async function () {
    try {
        await sequelize.authenticate();
        console.log('Connection has been established successfully.');
    } catch (error) {
        console.error('Unable to connect to the database:', error);
    }
    sequelize.sync().then(() => {
        console.log('数据库和表已成功创建');

        // //创建用户
        // User.create({
        //     userName: 'yuwu',
        //     gender:"1",
        //     age:18,
        //     email:"1",
        //     registrationTime:"2025-1-1"
        // })
    }).catch(err => {
        console.error('创建数据库和表时出错:', err);
    });
}